﻿#pragma once
#ifndef RGSFEATUREACTION_H
#define RGSFEATUREACTION_H

#include<QtMath>
#include<QAction>
#include<QUuid>
#include"Riskgis.h"
#include <qgsfeature.h>

class QgsVectorLayer;
class QgsAttributeDialog;
class QgsExpressionContextScope;



class RgsFeatureAction: public QAction
{
    Q_OBJECT
public:
    RgsFeatureAction(const QString &name, QgsFeature &f, QgsVectorLayer *vl,
                     QUuid actionId = QUuid(), int defaultAttr = -1, QObject *parent = nullptr );

    bool addFeature( const QgsAttributeMap &defaultAttributes = QgsAttributeMap(), bool showModal = true, QgsExpressionContextScope *scope = nullptr, bool hideParent = false );

    QgsFeature feature() const;
    //QgsAttributeDialog* newDialog(bool );

    void hideParentWidget();

signals:
    void addFeatureFinished();

public slots:
    void onFeatureSaved(const QgsFeature& f);
    void unhideParentWidget();

private:
    QgsAttributeDialog *newDialog( bool cloneFeature );

    QgsVectorLayer *mLayer = nullptr;
    QgsFeature *mFeature = nullptr;
    QUuid mActionId;
    int mIdx;

    bool mFeatureSaved;

    bool mForceSuppressFormPopup = false;
};

#endif // RGSFEATUREACTION_H
